package com.htfyun.fragment.library;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.htfyun.ScanMyBooksDirManager;
import com.htfyun.fragment.base.BaseWithPageNumberAdapter;
import com.htfyun.fragment.base.BaseWithPageNumberFragment;
import com.htfyun.view.CustomGridLayoutManager;

import org.geometerplus.zlibrary.ui.android.R;

import java.io.File;
import java.util.List;

/**
 * Created by sst on 2017/11/24.
 */

public class LibraryLocalBookFileFragment extends BaseWithPageNumberFragment<File> {

    LibraryBookRecyclerViewAdapter adapter;
    public static LibraryLocalBookFileFragment newInstance() {

        Bundle args = new Bundle();

        LibraryLocalBookFileFragment fragment = new LibraryLocalBookFileFragment();
        fragment.setArguments(args);
        return fragment;
    }


    @Override
    public RecyclerView.LayoutManager getLayoutManager() {
        
        return new CustomGridLayoutManager(_mActivity, getItemCountPerPage(),
                LinearLayoutManager.HORIZONTAL, false);
    }

    @Override
    public RecyclerView.ItemDecoration getDecor() {
        return null;
    }

    @Override
    public BaseWithPageNumberAdapter getAdapter() {
        if (adapter == null) {
            adapter = new LibraryBookRecyclerViewAdapter(_mActivity);
        }
        return adapter;
    }

    @Override
    public int getItemCountPerPage() {
        return getContext().getResources().getInteger(R.integer.library_book_count_per_page);

    }

    @Override
    public List<File> getTotalItemList() {
        return ScanMyBooksDirManager.INSTANCE.getFiles();
    }

    @Override
    public String getStringForTextEmpty() {
        return getString(R.string.push_books_into_my_book);

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        adapter.onDestroy();
    }
}
